# ser/ser/ser_service.py

import rclpy
from rclpy.node import Node
from std_srvs.srv import SetBool
from .number_processor import NumberProcessor

class NumberService(Node):
    def __init__(self):
        super().__init__('number_service')
        self.srv = self.create_service(SetBool, 'process_numbers', self.process_numbers_callback)
        self.processor = NumberProcessor()

    def process_numbers_callback(self, request, response):
        # if request.data:  # Sum
        n1 = float(input("Enter first number:"))
        n2 = float(input("Enter second number:"))
        n3 = float(input("Enter third number:"))
        self.processor.getNumbers([n1, n2, n3])
        result1 = self.processor.getSum()
        response.message = f'\nSum: {result1}\n'
        # else:  # Product
            # self.processor.getNumbers([1, 3, 3])
        result2 = self.processor.getProduct()
        response.message += f'Product: {result2}'
        response.success = True
        return response

def main(args=None):
    rclpy.init(args=args)
    node = NumberService()
    rclpy.spin(node)
    rclpy.shutdown()

if __name__ == '__main__':
    main()
